//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CVar.h>
///	@path	~/src/object/
///	@date	2007/06/25
///	@desc	IVar's most common implementation.

#pragma once

#include "xeres.h"

#include "object/IVar.h"
#include "object/varying_data.h"

namespace xeres {

	/*!
		\ingroup	iobject_module

		\class	CVar
		\brief	IVar's most common implementation.
				Encapsulate nearly all value access methods as a base.
		\details
			Implements all types of value access function in IVar, can be a most common variable type.
			CVar just uses VaryingData as its internal representation.
	*/
	class CVar : public IVar
	{
	public:

		/// \name Constructor & Destructor
		//@{

		/// \ctor
		CVar( void );

		/// \ctor
		explicit CVar( bool val );

		/// \ctor
		explicit CVar( int val );

		/// \ctor
		explicit CVar( float val );

		/// \ctor
		explicit CVar( double val );

		/// \ctor
		explicit CVar( const Pair<float>& val );

		/// \ctor
		explicit CVar( const Vector<float>& val );

		/// \ctor
		explicit CVar( const Quat<float>& val );

		/// \ctor
		explicit CVar( const Matrix<float>& val );

		/// \ctor
		explicit CVar( const WString& val );

		/// \ctor
		explicit CVar( RefWeak<IObject> val );

		/// \dtor
		virtual ~CVar( void );

		//@}

		DECL_IOBJECT_CLASS_DYNAMIC( CVar , IVar );

	public:

		/// \name Variable Type RTTI
		//@{

		/*!
			\return		Type name of variable.
		*/
		virtual const WString& GetVarTypeName( void ) const;

		/*!
			\return		Type ID of variable.
		*/
		virtual const ClassID GetVarTypeID( void ) const;

		//@}

		/// \name Variable Manipulation
		//@{

		/*!
			\return				Duplication result.<BR>
								CVar performs a deep copy of regular value,
								and duplicates reference for IObject instance.
		*/
		virtual bool DuplicateFrom( const Ref<IVar>& val );

		//@}

		// Set accessors.
		virtual bool SetBool( bool val );
		virtual bool SetInt( int val );
		virtual bool SetFloat( float val );
		virtual bool SetPair( const Pair<float>& val );
		virtual bool SetVector( const Vector<float>& val );
		virtual bool SetQuat( const Quat<float>& val );
		virtual bool SetColor( const Color4& val );
		virtual bool SetMatrix( const Matrix<float>& val );
		virtual bool SetString( const WString& val );

		virtual bool SetObject( RefWeak<IObject> val );

		// Get accessors.
		virtual bool GetBool( bool& val ) const;
		virtual bool GetInt( int& val ) const;
		virtual bool GetFloat( float& val ) const;
		virtual bool GetPair( Pair<float>& val ) const;
		virtual bool GetVector( Vector<float>& val ) const;
		virtual bool GetQuat( Quat<float>& val ) const;
		virtual bool GetColor( Color4& val ) const;
		virtual bool GetMatrix( Matrix<float>& val ) const;
		virtual bool GetString( WString& val ) const;

		virtual bool GetObject( Ref<IObject>& val ) const;

	private:

#ifndef _DOC_GEN

		// internal data representation
		VaryingData		m_data;

#endif /*_DOC_GEN*/

	};

} // namespace xeres
